#include <iostream>
#include "Nod.cpp"
#include "Frunza.cpp"
#include "Operator.h"
#include "Constanta.cpp"
#include "Necunoscuta.cpp"
#include "Plus.cpp"
#include "Minus.cpp"
#include "Inmultit.cpp"
#include "Impartit.cpp"
#include "Exp.cpp"
#include "Logaritm.cpp"
#include "Sin.cpp"
#include "Tangenta.cpp"
#include "Cotan.cpp"
#include "ASin.cpp"
#include "ACos.cpp"
#include "ATan.cpp"
#include "ACtg.cpp"
#include "Functie.cpp"
#include "Grafic.h"
#include <QApplication>
#include <QPainter>


Grafic::Grafic(QWidget *parent)
    : QWidget(parent)
{

}

void Grafic::paintEvent(QPaintEvent *event)
{

  Functie *f;
  char sir[]="sin(x)";
  f = new Functie(sir);
  QPen pen(Qt::black, 2, Qt::SolidLine);
  QPainter painter(this);
  painter.setPen(pen);
  painter.drawLine(20, 320, 620, 320);
  painter.drawLine(320, 20, 320, 620);
  QPen pen1(Qt::red, 2, Qt::SolidLine);
  painter.setPen(pen1);
  float k=-10,rezultat;
  int x=20;
  while(k<=10)
  {
    rezultat = f->calculezValoare(k);
    painter.drawPoint(intoarcePixelX(k),intoarcePixelY(rezultat));
    k=k+0.035;
  }
  QPen pen2(Qt::blue, 2, Qt::SolidLine);
  painter.setPen(pen2);
  k=-10;x=20;
  while(k<=10)
  {
    rezultat = f->calculezDerivata(k);
    painter.drawPoint(intoarcePixelX(k),intoarcePixelY(rezultat));
    k=k+0.035;
  }
  
}
